package com.example.onlineeducation.data.constant

import androidx.annotation.*
import com.example.onlineeducation.R
import com.yc.jetpacklib.extension.ycLoadImageRes

/**
 * 题目类型
 */
object ProblemType {
    /**
     * 单选题
     */
    const val SINGLE = 1

    /**
     * 多选题
     */
    const val MULTIPLE = 2

    /**
     * 判断题
     */
    const val JUDGMENT = 3

    @IntDef(SINGLE, MULTIPLE, JUDGMENT)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class Type

    @JvmStatic
    @Type
    fun toType(type: String?): Int {
        return when (type) {
            "01" -> SINGLE
            "02" -> MULTIPLE
            else -> JUDGMENT
        }
    }

    @JvmStatic
    fun getTypeName(@Type type: Int): String {
        return when (type) {
            SINGLE -> "单选题"
            MULTIPLE -> "多选题"
            else -> "判断题"
        }
    }

    @JvmStatic
    @DrawableRes
    fun getDrawable(@Type type: Int, isSelect: Boolean): Int {
        return when (type) {
            SINGLE -> {
                if (isSelect) {
                    R.drawable.problem_option_single_select
                } else {
                    R.drawable.problem_option_single_select_un
                }
            }
            MULTIPLE -> {
                if (isSelect) {
                    R.drawable.problem_option_multiple_select
                } else {
                    R.drawable.problem_option_multiple_select_un
                }
            }
            else -> {
                if (isSelect) {
                    R.drawable.problem_option_single_select
                } else {
                    R.drawable.problem_option_single_select_un
                }
            }
        }
    }

    @JvmStatic
    @ColorRes
    fun getTextColor(isSelect: Boolean): Int {
        return if (isSelect) {
            R.color.problem_option_tv_select
        } else {
            R.color.problem_option_tv_select_un
        }
    }

    @JvmStatic
    @ColorRes
    fun getBgColor(isSelect: Boolean): Int {
        return if (isSelect) {
            R.drawable.shape_ring_problem_option_select
        } else {
            R.drawable.shape_ring_problem_option_select_un
        }
    }
}